package com.ruoyi.system.controller;

import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.junit.jupiter.api.Test;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author : 赵贤
 * @create: 2023-03-15 10:44
 * @Description:
 */
@RequestMapping("test")
@RestController
@CrossOrigin
public class TestController {

    @Resource
    RocketMQTemplate rocketMQTemplate;

    @RequestMapping("test1")
    public void test2(){
        rocketMQTemplate.asyncSend("yk3", "hello word", new SendCallback() {
            @Override
            public void onSuccess(SendResult sendResult) {
                System.err.println("hello word");
            }

            @Override
            public void onException(Throwable throwable) {
                System.err.println("errrrrrrrrrrrrrro");

            }
        });
    }
}
